package 笔试.网易;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/18-19:29
 * @version:1.0
 * @function:
 */
public class Main05 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Long s = scanner.nextLong();
        Long num1 = s;
        Long num2 = tableSizeFor(s)-s;
        System.out.println(Math.min(fun(num1),fun(num2)+1));
    }
    static int fun(Long num){
        int count = 0;
        while (num>0){
            int temp = (int) (num & 1);
            if (temp==1)
                count++;
            num = num>>1;
        }
        return count;
    }
    static Long tableSizeFor(Long cap) {
        Long n = cap - 1;
        n |= n >>> 1;
        n |= n >>> 2;
        n |= n >>> 4;
        n |= n >>> 8;
        n |= n >>> 16;
        n |= n >>> 32;
        return n+1;
    }

}
